package com.henu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.henu.R;
import com.henu.xyh.entity.Reply;

import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by xing on 2017/5/17.
 */

public class ListReplyAdapter extends BaseAdapter {

    private ArrayList<Reply> list=new ArrayList<>();
    LayoutInflater inflater;
    public ListReplyAdapter(Context context)
    {
        inflater=LayoutInflater.from(context);
    }
    public void addData(ArrayList<Reply> templist)
    {
        list.clear();
        list.addAll(templist);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view==null)
        {
            view= inflater.inflate(R.layout.inflate_lv_reply_item,null);
        }
        TextView author= (TextView) view.findViewById(R.id.reply_author);
        TextView content= (TextView) view.findViewById(R.id.reply_content);
        TextView time= (TextView) view.findViewById(R.id.reply_time);
        Reply e=list.get(i);
        author.setText(e.getUser_Id().getUsername());
        content.setText(e.getReply_Message());
        time.setText(e.getCreatedAt());
        return view;
    }
}
